<template>
  <div class="nav-header">
    <i
      class="fold-menu"
      :class="isFold ? 'el-icon-s-fold' : 'el-icon-s-unfold'"
      @click="handleFold"
    ></i>
    <div class="centent">
      <TBreadcrumb :breadcrumbs="breadcrumbs" />
      <userinfo />
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, computed } from 'vue'
import userinfo from './user-info.vue'
import TBreadcrumb from '../../../base-ui/breadcrumb'
import { useStore } from '@/store'
import { useRoute } from 'vue-router'
import { pathMapBreadcrumb } from '../../../utils/map-menu'

const isFold = ref(false)
const emit = defineEmits(['foldChange'])
const handleFold = () => {
  isFold.value = !isFold.value
  emit('foldChange', isFold.value)
}

const store = useStore()

const breadcrumbs = computed(() => {
  const userMenu = store.state.login.userMenus

  const route = useRoute()
  const rourePath = route.path
  return pathMapBreadcrumb(userMenu, rourePath)
})
</script>
<style lang="less">
.nav-header {
  display: flex;
  width: 100%;
  .fold-menu {
    font-size: 30px;
    cursor: pointer;
  }

  .centent {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
    padding: 0 20px;
  }
}
</style>
